<template>
	<view>
    <view class="tabList">
      <u-tabs :list="tabList" @click="tabClick"></u-tabs>
    </view>
    <view class="hotel">
      <view v-for="item in waterfall_list" class="hotel" @click="go('/pagesA/index_menu/whotel_d?id='+item.id)">
        <image :src="item.image"></image>
        <view class="title">
          <view class="line1">
            <view>{{item.title}}</view>
            <view>{{item.score}}分</view>
          </view>
          <view class="line2">
            <view class="tag">
              <!-- <view v-for="item in 3"><u-tag text="标签" type="warning" plain plainFill></u-tag></view> -->

              <view v-for="item2 in item.lable_multiplejson">
				<u-tag :text=item2.time type="warning" plain plainFill></u-tag>
			 </view>

            </view>
            <view class="price">
              <text class="name">价格</text>
              <text class="money">￥{{item.price}}起</text>
            </view>
          </view>
        </view>
      </view>
    </view>

	</view>
</template>

<script>
	import {whotellists,whoteltype} from "../../api/index_menu";

  export default {
		data() {
			return {
        waterfall_list:[],
        tabList: [{
          name: '全部',
        }, {
          name: '阿勒泰线',
        }, {
          name: '伊黎线',
        }],
		query: {
			sort: 1,
			page: 1,
			search: '',
			type_id: ''
		},
			}
		},
    onLoad() {
      this.get_lists();
	  this.whoteltype();
    },
		methods: {
			go(url) {
				uni.navigateTo({
					url
				})
			},
      toDetail(item) {
        uni.navigateTo({
            url: `/pages/whotel/hotelDetail?id=${item.id}`,
        })
      },
      tabClick(index){
        console.log(index)
		
		// console.log(index,this.ticket_type_list)
		// this.ticket_type_list[index].action = !this.ticket_type_list[index].action
		// this.$forceUpdate()
		this.query.type_id = index.id;
		// this.query.type_id = this.ticket_type_list[index].id;
	
		this.query_data(this.query)
		
      },
	  
	  // 获取门票类型
	  whoteltype() {
	  	whoteltype().then(res => {
	  		// console.log(res)
	  		if (res.code == 1) {
	  			let arr = []
	  			res.data.data.forEach(item => {
	  				item.action = false
	  				arr.push(item)
	  			})
	  			this.tabList = arr
	  		}
	  	})
	  },
	  
	  
	  query_data(obj) {
	  	// 每次筛选清空page
	  	this.query.page = 1
	  	this.waterfall_list = []
	  	this.query = { ...this.query, ...obj }
	  	// console.log(this.query)
	  	this.get_lists()
	  },
	  
      get_lists() {
        whotellists(this.query).then(res => {
          if (res.code == 1) {
            this.waterfall_list = res.data.data
          }
        })
      },
		}
	}
</script>

<style lang="scss">
page{
  background-color: #f5f5f5;
}
.tabList{
  background-color: white;
}
.hotel{
  padding: 0 20rpx;
}
</style>
